package com.letao.action;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.json.annotations.JSON;

import com.letao.pojo.Category;
import com.letao.pojo.Goods;
import com.letao.service.GoodsServiceInterface;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class LocationAction extends ActionSupport{
	private GoodsServiceInterface goodsServiceInterface;
	private String location;//The latitude and longitude
	private Double r;//Radius
	private Category category;//Store Category Cname
	private Goods goods;//Store Goods Gname
	private List<Goods> goodsList;
	public String findNearGoods()throws Exception{
		if(category!=null){//Select goods according to the Category Cname
			goodsList=goodsServiceInterface.getGoodsByCategoryAndLocation(category.getCid(), location, r);
			return INPUT;
		}
		if(goods!=null){//Select goods according to the Goods Gname
			goodsList=goodsServiceInterface.getGoodsByNameAndLocation(goods.getGname(), location, r);
			return INPUT;
		}
		goodsList=goodsServiceInterface.getGoodsByLocation(location, r);
		return INPUT;
	}
	public String getLocation() {
		return location;
	}
	public void setLocation(String location) {
		this.location = location;
	}
	public Category getCategory() {
		return category;
	}
	public void setCategory(Category category) {
		this.category = category;
	}
	public Goods getGoods() {
		return goods;
	}
	public void setGoods(Goods goods) {
		this.goods = goods;
	}
	public GoodsServiceInterface getGoodsServiceInterface() {
		return goodsServiceInterface;
	}
	public void setGoodsServiceInterface(GoodsServiceInterface goodsServiceInterface) {
		this.goodsServiceInterface = goodsServiceInterface;
	}
	public Double getR() {
		return r;
	}
	public void setR(Double r) {
		this.r = r;
	}
	public List<Goods> getGoodsList() {
		return goodsList;
	}
	public void setGoodsList(List<Goods> goodsList) {
		this.goodsList = goodsList;
	}
}
